 <?php
 //szczecin
  $lat=53.430606;
  $lng=14.556541;
  $zoom=12;
  $width=620;
  $height=680;
  $markerColor = array ("red","blue","yellow","purple","violet","black","pink","green","gray","lightgreen","turquoise","orange","darkgray", "lightblue","beige", "white", "brown","darkgreen" );

?>
Popularne kategorie:
<input type="button" id="btn16" onclick="reloadMap(16, true)" value="stacje beznynowe">
<input type="button" id="btn5" onclick="reloadMap(5, true)" value="bankomaty"><br>
 promień: <span id="range">3.10</span>km
 <input value="3.10" type="hidden" id="inr" >
 <!-- <input id="inr" disabled size="4" value="0.10" type="text" onchange="reloadMap(5, true)">km -->
<div class="slider4">
   <div  class="indicator" id="indicator2">&nbsp;</div>
	<div class="indicator" id="indicator3">&nbsp;</div>
</div>
max liczba punktów:<input type="text" value="5" id="ini" onchange="reloadMap(5, true)" size="3" >
<input type="button" id="genDir" onclick="generateDirection()" value="Wyznacz trasę" >

<div id="map" class="dymek" style="width: <?php echo $width; ?>px; height: <?php echo $height; ?>px">
      </div>

<div id="current_points">
   <!--  wyświetla tabele z punktami widocznymi obecnie na mapie
   tabela umozliwia dodanie punktow do listy -->
   <?php include('currentPoints.php');
   ?>
</div>
 <div id="side_bar"></div>

 <div id="directions"></div>
      <script type="text/javascript">
      //<![CDATA[

var map;
var bounds;

// === Create an associative array of GIcons() ===
var gicons = [];
<?php
foreach($markerColor as $color)
{
   echo 'gicons["'.$color. '"] = new GIcon(G_DEFAULT_ICON, "images/markers/'.$color.'.png");'. PHP_EOL;
}
?>

initGMap();


 map.addControl(new GScaleControl() );
 // deklaracja ikonki numer jeden
 var ikona = new GIcon();
 ikona.image = "http://maps.google.com/mapfiles/kml/pal3/icon46.png";
 ikona.iconSize = new GSize(32, 32);
 ikona.iconAnchor = new GPoint(16,16);

 var ikona_start = new GIcon();
 ikona_start.image = "http://www.google.com/intl/en_ALL/mapfiles/markerA.png";


var cross =  new GMarker(new GLatLng(53.380043,14.648995),{icon: ikona});
var marker_start = new GMarker(new GLatLng(53.380043,14.648995),{icon: ikona_start});
map.setCenter(new GLatLng(53.380043, 14.648995), 13);
map.addOverlay(cross);
var map_moveend_listener = GEvent.addListener(map,'moveend',this.reloadMap);

var waypoints = [];
var dirPanel = document.getElementById('directions');
var directions = new GDirections(null, dirPanel);
var polilinia;

   GEvent.addListener(directions,"error", function() {
      GLog.write('GDirections error nr: '+directions.getStatus().code);
     // map_moveend_listener = GEvent.addListener(map,'moveend',this.reloadMap);
      polilinia = null;
   });
   GEvent.addListener(directions,"addoverlay", function() {
      GLog.write('GDirections added overlay EVENT');
      if (polilinia)
         map.removeOverlay(polilinia);
      polilinia = directions.getPolyline();
     // map_moveend_listener = GEvent.addListener(map,'moveend',this.reloadMap);
      map.addOverlay(polilinia);
   });

   function readMap(url) {
      var url="external/findj.php?"+url;
      if (window.XMLHttpRequest) {
         var request  = new XMLHttpRequest();
       //  GLog.write('new XMLHttpRequest()');
      }
else if (window.ActiveXObject) {
   var request  = new ActiveXObject("Microsoft.XMLHTTP");
    GLog.write('new ActiveXObject()');
}
      request.open("GET", url, true);
      
      request.onreadystatechange = function() {
         if (request.readyState == 4) {
            if (request.status == 200) {
               if (request.responseText)
                  {
               var jsonData = eval("("+request.responseText+")");
               // hide the info window, otherwise it still stays open where the removed marker used to be
               map.getInfoWindow().hide();
                map.clearOverlays();
                GLog.write('map.clearOverlays()');
               // empty the array
              gmarkers.splice(0);
              gmarkers.length = 0;
              // gmarkers.clear();
               side_bar_html="";// reset the side_bar
               //GLog.write('ilość obiektów w pliku json: ' +jsonData.length)
                var tbody = document.getElementById('currentPoints_tbody');
                tbody.innerHTML = '';
                document.getElementById('current_points').style.display='inline';
                
               for (var i = 0; i < jsonData.length; i++) {
                  // obtain the attribues of each marker
                  var point = new GLatLng(jsonData[i].lat, jsonData[i].lon);
                  var html = jsonData[i].name;
                  var label =jsonData[i].desc;
                  var dystans = jsonData[i].dystans.toFixed(3);
                  var ico = jsonData[i].ico;
                  var marker = addMarkerAndExtendedDesc(jsonData[i].id, point,label,"<b>"+html+"</b>",label, dystans, ico);
                  appendRow( tbody, jsonData[i].id, jsonData[i].lat, jsonData[i].lon, html, label);
                  //GLog.write('marker id=' + marker.id);
                  map.addOverlay(marker);
               }
               GLog.write('Dodano '+jsonData.length+' markerow');
               // put the assembled side_bar_html contents into the side_bar div
               document.getElementById("side_bar").innerHTML = side_bar_html;
               map.addOverlay(cross);
                  }
                  else
            {
               GLog.write('Brak wynikow zapytania');
               document.getElementById('currentPoints_tbody').innerHTML = '';
               document.getElementById('current_points').style.display='none';
               
               map.getInfoWindow().hide();
                map.clearOverlays();
                gmarkers.splice(0);
               //gmarkers = [];// empty the array
               gmarkers.length = 0;
               document.getElementById("side_bar").innerHTML = "Brak POI w zadanym obszarze. Spróbuj przesunąć mapę lub zwiększyć promień wyszukiwania.";// reset the side_bar
                map.addOverlay(cross);
            }
            if (polilinia)
               {
                 map.addOverlay(polilinia);
               }       
            }
         }
      }
      request.send(null);
   }

//var map_moveend_listener = GEvent.addListener(map,'moveend',this.reloadMap);
readMap('lon=14.658&lat=53.383&r=5&i=6');
//***** jQuery start here: *****//
$j(function() {// call the tablesorter plugin
    $j("#points_table").tablesorter({ headers: { 0:{sorter: false}, 3:{sorter: false}} });
});
      //]]>
      </script>